package com.example.zkfx.adapter

import android.graphics.Paint
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.Goods
import com.example.zkfx.R


class GoodsAdapter:BaseQuickAdapter<Goods,BaseViewHolder>(R.layout.item_goods) {
    override fun convert(holder: BaseViewHolder, item: Goods) {
        //GlideUtils.loadCorner(context,item.image,holder.getView(R.id.goods_image),20)
        Glide.with(context).load(item.image).into(holder.getView(R.id.goods_image))
        holder.setText(R.id.goods_storeName,item.storeName)
        holder.setText(R.id.goods_price,"￥${item.price}")
        holder.setText(R.id.goods_otPrice,"￥${item.otPrice}")
        //将实体类中的sales和ficti的类型改为Int ***在项目中sales+ficti才是真正的销售数量
        holder.setText(R.id.goods_sale,"已售${item.sales+item.ficti}件")
        //给原价textView添加中划线
        val textView = holder.getView<TextView>(R.id.goods_otPrice)
        textView.paintFlags = Paint.STRIKE_THRU_TEXT_FLAG//设置中划线
    }
}